<layout name="Common/layout"/>

    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>收货地址</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/style/home.css" type="text/css">
    <link rel="stylesheet" href="__PUBLIC__/Home/style/address.css" type="text/css">
    <link rel="stylesheet" href="__PUBLIC__/Home/style/order.css" type="text/css">

    <script type="text/javascript" src="__PUBLIC__/Home/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Home/js/home.js"></script>

<div style="clear:both;"></div>

<!-- 头部 start -->
<include file="Common/nav"/>
<!-- 头部 end-->

<div style="clear:both;"></div>

<!-- 页面主体 start -->
<div class="main w1210 bc mt10">
    <div class="crumb w1210">
        <h2><strong>我的XX </strong><span>> 我的订单</span></h2>
    </div>

    <!-- 左侧导航菜单 start -->
    <include file="My/menu" />
    <!-- 左侧导航菜单 end -->

    <!-- 右侧内容区域 start -->
    <div class="content fl ml10">
        <div class="address_hd">
            <h3>收货地址薄</h3>
            <?php
            $max_key = max(array_keys($data));
            foreach($data as $k=> $v):
               ?>
            <dl <?php if($max_key == $k):?>class="last"<?php endif;?>>
                <dt>
                    <?php echo $k+1;?>.
                    <?php echo $v[consignee];?>
                    <?php echo $v[province][region_name];?>
                    <?php echo $v[city][region_name];?>
                    <?php echo $v[district][region_name];?>
                    <?php echo $v[address];?>
                    <?php echo $v[mobile];?>
                    <?php if($v[is_default]==1):?><font color="red">[默认]</font><?php endif;?>
                </dt>
                <dd>
                    <a href="<?php echo U('UserAddress/edit',array('id'=>$v[id]));?>" >修改</a>
                    <a href="<?php echo U('UserAddress/delete',array('id'=>$v[id]));?>" onclick="if(!confirm('是否要删除该地址?')){return false}">删除</a>
                    <a href="<?php echo U('UserAddress/setDefault',array('id'=>$v[id]));?>" onclick="if(!confirm('是否要设置为默认地址?')){return false}">设为默认地址</a>
                </dd>
            </dl><!---->
            <?php endforeach; ?>
        </div>

        <div class="address_bd mt10">
            <h4>新增/修改收货地址</h4>
            <form action="<?php if($info):echo U('UserAddress/edit');else:echo U('UserAddress/add');endif;?>" name="address_form" method="post">
                <ul>
                    <li>
                        <label for=""><span>*</span>收 货 人：</label>
                        <input type="text" name="consignee" class="txt" value="<?php echo $info[consignee];?>"/>
                    </li>
                    <li>
                        <label for=""><span>*</span>所在地区：</label>
                        <select name="province" id="province">
                            <option value="">请选择</option>
                        </select>

                        <select name="city" id="city">
                            <option value="">请选择</option>
                        </select>

                        <select name="district" id="district">
                            <option value="">请选择</option>
                        </select>
                    </li>
                    <li>
                        <label for=""><span>*</span>详细地址：</label>
                        <input type="text" id="address" name="address" class="txt address" value="<?php echo $info[address];?>" />
                    </li>
                    <li>
                        <label for=""><span>*</span>手机号码：</label>
                        <input type="text" id="mobile" name="mobile" class="txt" value="<?php echo $info[mobile];?>"/>
                    </li>
                    <li>
                        <label for="">&nbsp;</label>
                        <input type="checkbox" id="is_default" name="is_default" class="check" value="1" <?php if($info[is_default]==1):?>checked<?php endif;?>/>设为默认地址
                    </li>
                    <li>
                        <label for="">&nbsp;</label>
                        <input type="submit" name="" class="btn" value="保存" />
                        <input type="hidden" name="id" value="<?php echo $info[id];?>">
                    </li>
                </ul>
            </form>
        </div>

    </div>
    <!-- 右侧内容区域 end -->
</div>
<!-- 页面主体 end-->

<div style="clear:both;"></div>

<!-- 底部导航 start -->
<div class="bottomnav w1210 bc mt10">
    <div class="bnav1">
        <h3><b></b> <em>购物指南</em></h3>
        <ul>
            <li><a href="">购物流程</a></li>
            <li><a href="">会员介绍</a></li>
            <li><a href="">团购/机票/充值/点卡</a></li>
            <li><a href="">常见问题</a></li>
            <li><a href="">大家电</a></li>
            <li><a href="">联系客服</a></li>
        </ul>
    </div>

    <div class="bnav2">
        <h3><b></b> <em>配送方式</em></h3>
        <ul>
            <li><a href="">上门自提</a></li>
            <li><a href="">快速运输</a></li>
            <li><a href="">特快专递（EMS）</a></li>
            <li><a href="">如何送礼</a></li>
            <li><a href="">海外购物</a></li>
        </ul>
    </div>


    <div class="bnav3">
        <h3><b></b> <em>支付方式</em></h3>
        <ul>
            <li><a href="">货到付款</a></li>
            <li><a href="">在线支付</a></li>
            <li><a href="">分期付款</a></li>
            <li><a href="">邮局汇款</a></li>
            <li><a href="">公司转账</a></li>
        </ul>
    </div>

    <div class="bnav4">
        <h3><b></b> <em>售后服务</em></h3>
        <ul>
            <li><a href="">退换货政策</a></li>
            <li><a href="">退换货流程</a></li>
            <li><a href="">价格保护</a></li>
            <li><a href="">退款说明</a></li>
            <li><a href="">返修/退换货</a></li>
            <li><a href="">退款申请</a></li>
        </ul>
    </div>

    <div class="bnav5">
        <h3><b></b> <em>特色服务</em></h3>
        <ul>
            <li><a href="">夺宝岛</a></li>
            <li><a href="">DIY装机</a></li>
            <li><a href="">延保服务</a></li>
            <li><a href="">家电下乡</a></li>
            <li><a href="">京东礼品卡</a></li>
            <li><a href="">能效补贴</a></li>
        </ul>
    </div>
</div>
<!-- 底部导航 end -->

<div style="clear:both;"></div>
<!-- 底部版权 start --><!-- 底部版权 end -->
<script>
   $(function () {
       $.ajax({
           url:'<?php echo U("UserAddress/Region");?>',
           type:'get',
           dataType:'json',
           success:function (data) {
               $.each(data,function (k,v) {
                   $("#province").append("<option value='"+v.region_id+"'>"+v.region_name+"</option>");
               });
           }
       });

       $("#province,#city").change(function () {
           var select = $(this);
           $.ajax({
               url:'<?php echo U("UserAddress/Region");?>',
               type:'get',
               data:'id='+select.val(),
               dataType:'json',
               success:function (data) {
                   select.nextAll("select").empty().append(new Option('请选择'));
                   $.each(data,function (k,v) {
                       select.next().append(new Option(v.region_name,v.region_id));
                   })
               }
           });
       });
   });

    //修改
   var onclick_edit;
   onclick_edit = $(function () {
       <?php if($info): ?>
       var region = {province:"<?php echo $info['province']; ?>",city:"<?php echo $info['city']; ?>", district:"<?php echo $info['district']; ?>"};
       $.each(region,function (region_name,region_id) {
           if(region_name == 'province'){
               parent_region_id = 1;
           } else if(region_name == 'city'){
               parent_region_id = region.province;
           } else if(region_name == 'district'){
               parent_region_id = region.city;
           }
           $.ajax({
               url : '<?php echo U("UserAddress/region"); ?>',
               type : 'get',
               data : 'id='+parent_region_id,
               dataType : 'json',
               success : function (data) {
                   $.each(data,function (k,v) {
                       $('#'+region_name).append(new Option(v.region_name,v.region_id,(region_id==v.region_id ? true : false),(region_id==v.region_id ? true : false)));
                   });
               }
           });
       });
   });
   <?php else: ?>
   $.ajax({
       url : '<?php echo U("UserAddress/Region"); ?>',
       type : 'get',
       dataType : 'json',
       success : function (data) {
           $.each(data, function (k, v) {
               $('#province').append(new Option(v.region_name, v.region_id));
           });

       }

   });

   });
   <?php endif; ?>
</script>
</body>
</html>

